package com.sgb.kjwl.view.ui.adapter.packers;

import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.sgb.kjwl.BR;
import com.sgb.kjwl.R;
import com.sgb.kjwl.model.entity.request.PackersProjectTeamListEntity;
import com.swgk.core.recyclerview.adapter.BaseRecycleAdapter;
import com.swgk.core.recyclerview.adapter.ItemViewHolder;
import com.swgk.core.util.DateUtils;

import java.util.List;

/**
*@author kobe577590
*@date 2020/6/12
*description:
*/
public class PackersProjectTeamListAdapter extends BaseRecycleAdapter<PackersProjectTeamListEntity> {

    public PackersProjectTeamListAdapter(Context context, List<PackersProjectTeamListEntity> data) {
        super(context, R.layout.item_packers_project_teams, data);
    }

    @Override
    public void convert(ItemViewHolder holder, final PackersProjectTeamListEntity entity) {
        holder.setBinding(BR.viewModel, entity);
        ImageView imgTab = holder.itemView.findViewById(R.id.img_tab);
        TextView tvEndTime = holder.itemView.findViewById(R.id.tv_endTime);
        TextView tvType = holder.itemView.findViewById(R.id.tv_type);
        TextView typeType = holder.itemView.findViewById(R.id.type_type);
        imgTab.setVisibility(View.VISIBLE);

        try {
            if(null!=entity.getScopes() && entity.getScopes().size()>0){
                typeType.setText(String.format("%s-%s-%s",entity.getScopes().get(0).getFirstCategoryName() , entity.getScopes().get(0).getSecondCategoryName() , entity.getScopes().get(0).getThirdCategoryName()));
            }else{
                typeType.setText("");
            }
        } catch (Exception e) {
            e.fillInStackTrace();
        }

        if(!TextUtils.isEmpty(entity.getCreateTime())){
            tvEndTime.setText(DateUtils.stampToDay(entity.getCreateTime()));
        }else{
            tvEndTime.setText("");
        }


        if(entity.getIsCompany() == 1){
            //企业
            tvType.setText("企业");
        }else{
            tvType.setText("个人");
        }

    }
}
